// 配置layout下的子路由

import tooliddef from './tooliddef';

const getUrlAndLink = (arr, targetArr) => {
  arr.forEach(x => {
    if (x.menus && x.menus.length) getUrlAndLink(x.menus, targetArr);
    else targetArr.push(x);
  });
  return targetArr;
}

const targetArr = getUrlAndLink(tooliddef, []);

const routes = targetArr.map(x => {
  return {
    path: x.link, component: x.url, exact: true,
  }
});
// 添加首页重定向
routes.unshift({ path: '/', exact: true, redirect: '/map' });

// 注册当前项目的路由表
export default [
  {
    // 登录路由
    path: '/login',
    component: './login/view', exact: true,
  },
  {
    path: '/',
    component: '../layouts/index',
    wrappers: [
      '@/utils/auth.js',
    ],
    routes,
  },

]


// 可视化路由表
/* const routes = [
  {
    path: '/', exact: true, redirect: '/home'
  },
  {
    path: '/home', component: './home/view',
  },
  {
    path: '/map', component: './map/view',
  },
  {
    path: '/echarts', component: './echarts/view',
  },
  {
    path: '/info/project', component: './projectInfo/view',
  },
  {
    path: '/info/contract', component: './contractInfo/view',
  },
  {
    path: '/info/finance', component: './financeInfo/view',
  },
  {
    path: '/plan/year', component: './planYear/view',
  },
  {
    path: '/plan/whole', component: './planWhole/view',
  },
  {
    path: '/engineer/inside', component: './engineerInside/view',
  },
  {
    path: '/engineer/outside', component: './engineerOutside/view',
  },
  {
    path: '/management/personal', component: './personalInfo/view',
  },
  {
    path: '/management/relationship', component: './relationship/view',
  },
  {
    path: '/about', component: './aboutUs/view',
  },
]; */
